/*
 *  Copyright 2008 Mark Ashworth <javameme@gmail.com>.
 *
 *  Licensed under the GNU General Public License v3 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.gnu.org/licenses/gpl-3.0.html
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package xperiment.metaphor.model.contact;

import xperiment.metaphor.model.*;
import java.io.Serializable;

/**
 * Address
 * @author Mark Ashworth
 * @version 1.0.0
 */
public class Address extends AbstractBean implements Serializable {
    private static final long serialVersionUID = 1L;

    /** Address information */
    private String address01;
    private String address02;
    private String address03;
    private String postalCode;
    
    public String getAddress01() {
        return address01;
    }

    public void setAddress01(String address01) {
        String old = this.address01;
        this.address01 = address01;
        firePropertyChange("address01", old, getAddress01());
    }

    public String getAddress02() {
        return address02;
    }

    public void setAddress02(String address02) {
        String old = this.address02;
        this.address02 = address02;
        firePropertyChange("address02", old, getAddress02());
    }

    public String getAddress03() {
        return address03;
    }

    public void setAddress03(String address03) {
        String old = this.address03;
        this.address03 = address03;
        firePropertyChange("address03", old, getAddress03());
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        String old = this.postalCode;
        this.postalCode = postalCode;
        firePropertyChange("postalCode", old, getPostalCode());
    }
    
    /**
     * &lt;address address01="" address02="" address03="" code="" /&gt;<br />
     * @return String 
     */
    public String toXML() {
        return toXML("address");
    }
    
    /**
     * Returns the XML but sets the node name to the value passes, for example
     * if the nodeName of 'physical_address' was used then the following would
     * be returned.<br />
     * 
     * &lt;physical_address address01="" address02="" address03="" code="" /&gt;<br />
     * 
     * @param nodeName The name of the address node
     * @return String
     */
    public String toXML(String nodeName) {
        
        return "<" + nodeName + " class='"+ getClass().getName() 
                + "' address01='" + getAddress01()
                + "' address02='" + getAddress02()
                + "' address03='" + getAddress03()
                + "' code='" + getPostalCode()
                + "' />";
    }
}
